#include<cstdio>
#include<cstring>
int n;
struct node{
	bool val;
	int pre,nxt;
}a[200010];
bool del[200010];
int main(){
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i].val);
		a[i].pre=i-1,a[i].nxt=i+1;
	}
	a[0].nxt=1,a[1].pre=0;
	a[n].nxt=n+1,a[n+1].pre=n;
	while(a[0].nxt<=n){
		memset(del,0,sizeof(del));
		for(int i=a[0].nxt,j;i<=n;i=j){
			j=a[i].nxt;
			if(!a[i].pre||a[a[i].pre].val^a[i].val){
				printf("%d ",i);
				del[i]=true;
			}
		}
		putchar('\n');
		for(int i=a[0].nxt,j;i<=n;i=j){
			j=a[i].nxt;
			if(del[i]){
				a[a[i].pre].nxt=a[i].nxt;
				a[a[i].nxt].pre=a[i].pre;
			}
		}
	}
	return 0;
}
